package cn.fulong.frame.service.impl;

import cn.fulong.frame.config.Platform;
import cn.fulong.frame.service.GetData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service("getDataFromCache")
public class GetDataFromCache extends GetData {

    @Override
    public Map execute(Map dataset, Map args) {
        Object oSQL = dataset.get("sql");
        if (oSQL == null) {
            log.info("缺少SQL参数");
            return null;
        }
        String sql = oSQL.toString();
        List data = Platform.getInstance().getDicList(sql);
        //List data = Platform.getInstance().getDicOptions(sql);

        String ds = dataset.get("name").toString();
        Map result = new HashMap();
        result.put(ds, data);
        return result;
    }
}
